/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package battleship_server.threads;

import battleship_server.Manager;
import battleship_server.SocketConnection;
import java.util.logging.Level;
import java.util.logging.Logger;


/**
 *
 * @author omar
 */
public class GameCreationThread extends Thread{
    
    @Override
    public void run(){
        while(true){
            try {
                if (Manager.queuedPlayers.size() > 1) {
                    SocketConnection uno = Manager.queuedPlayers.poll();
                    SocketConnection dos = Manager.queuedPlayers.poll();
                    GameLogicThread glt = new GameLogicThread(uno, dos);
                    glt.start();
                    Manager.games.add(glt);
                }
                Thread.sleep(1000);
            } catch (InterruptedException ex) {
                Logger.getLogger(GameCreationThread.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
}
